package thread;
public class threadDeom1 {
    public static void main(String[] args) {
        //构造实例
        //mythread t=new mythread();
        Thread t=new mythread();
        t.start();
        while (true){
            System.out.println("这是main线程");
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
                throw new RuntimeException();
            }
        }
    }
}
//写一个类继承thrad
class mythread extends Thread{
    //重写run方法,该线程的入口方法
    @Override
    public void run(){
        while (true){
            System.out.println("这是thread线程");
            //防止打印过快
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
                throw new RuntimeException();//抛出异常
            }
        }
    }
}
